package controllers

import (
	"github.com/astaxie/beego"
	"beegoProject/models"
	"fmt"
	"encoding/json"
)

type MyController struct {
	beego.Controller
}

func (c *MyController) Test1() {
	var user models.User
	data := c.Ctx.Input.RequestBody
	fmt.Println("aaaaaaaaaaaaaaa", data, c.Ctx.Input)
	err := json.Unmarshal(data, &user)
	if err != nil{
		c.Data["json"] = models.Msg{1, "err"}
		c.ServeJSON()
		return
	}
	res, errQuery := models.QueryOne(user.Id)
	if errQuery != nil{
		c.Data["json"] = models.Msg{1, "err"}
	}else {
		c.Data["json"] = models.Msg{Code: 0, Data: &res}
	}
	c.ServeJSON()
	return
}
